home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June (Extra) / CHIP 2006-06.3.iso / program / opensource / clamav-devel.exe / contrib / Windows / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-16  |  4.3 KB  |  177 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. /*
  5.  *  Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk>
  6.  *
  7.  *  This program is free software; you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation; either version 2 of the License, or
  10.  *  (at your option) any later version.
  11.  *
  12.  *  This program is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with this program; if not, write to the Free Software
  19.  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20.  *  MA 02110-1301, USA.
  21.  */
  22. #include "stdafx.h"
  23. #include "mainfrm.h"
  24. #include "resource.h"
  25. #include "clamav.h"
  26.  
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMainFrame
  35.  
  36. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  37.  
  38. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  39.     //{{AFX_MSG_MAP(CMainFrame)
  40.     ON_WM_CREATE()
  41.     ON_WM_DROPFILES()
  42.     //}}AFX_MSG_MAP
  43.     // Global help commands
  44.     ON_COMMAND(ID_HELP_INDEX, CFrameWnd::OnHelpIndex)
  45.     ON_COMMAND(ID_HELP_USING, CFrameWnd::OnHelpUsing)
  46.     ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
  47.     ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
  48.     ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpIndex)
  49. END_MESSAGE_MAP()
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // arrays of IDs used to initialize control bars
  53.     
  54. // toolbar buttons - IDs are command buttons
  55. static UINT BASED_CODE buttons[] =
  56. {
  57.     // same order as in the bitmap 'toolbar.bmp'
  58.     ID_FILE_NEW,
  59.     ID_FILE_OPEN,
  60.     ID_FILE_SAVE,
  61.         ID_SEPARATOR,
  62.     ID_EDIT_CUT,
  63.     ID_EDIT_COPY,
  64.     ID_EDIT_PASTE,
  65.         ID_SEPARATOR,
  66.     ID_FILE_PRINT,
  67.     ID_APP_ABOUT,
  68.     ID_CONTEXT_HELP,
  69. };
  70.  
  71. static UINT BASED_CODE indicators[] =
  72. {
  73.     ID_SEPARATOR,           // status line indicator
  74.     ID_INDICATOR_CAPS,
  75.     ID_INDICATOR_NUM,
  76.     ID_INDICATOR_SCRL,
  77. };
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CMainFrame construction/destruction
  81.  
  82. CMainFrame::CMainFrame()
  83. {
  84.     // TODO: add member initialization code here
  85.     
  86. }
  87.  
  88. CMainFrame::~CMainFrame()
  89. {
  90. }
  91.  
  92. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  93. {
  94.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  95.         return -1;
  96.  
  97.     
  98.     if (!m_wndToolBar.Create(this) ||
  99.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  100.         !m_wndToolBar.SetButtons(buttons,
  101.           sizeof(buttons)/sizeof(UINT)))
  102.     {
  103.         TRACE0("Failed to create toolbar\n");
  104.         return -1;      // fail to create
  105.     }
  106.  
  107.     if (!m_wndStatusBar.Create(this) ||
  108.         !m_wndStatusBar.SetIndicators(indicators,
  109.           sizeof(indicators)/sizeof(UINT)))
  110.     {
  111.         TRACE0("Failed to create status bar\n");
  112.         return -1;      // fail to create
  113.     }
  114.  
  115.     m_wndToolBar.DestroyWindow();
  116. #if    0
  117.     // TODO: Delete these three lines if you don't want the toolbar to
  118.     //  be dockable
  119.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  120.     EnableDocking(CBRS_ALIGN_ANY);
  121.     DockControlBar(&m_wndToolBar);
  122.  
  123.     // TODO: Remove this if you don't want tool tips
  124.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  125.         CBRS_TOOLTIPS | CBRS_FLYBY);
  126. #endif
  127.     DragAcceptFiles(TRUE);
  128.  
  129.     return 0;
  130. }
  131.  
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CMainFrame diagnostics
  134.  
  135. #ifdef _DEBUG
  136. void CMainFrame::AssertValid() const
  137. {
  138.     CFrameWnd::AssertValid();
  139. }
  140.  
  141. void CMainFrame::Dump(CDumpContext& dc) const
  142. {
  143.     CFrameWnd::Dump(dc);
  144. }
  145.  
  146. #endif //_DEBUG
  147.  
  148. void
  149. CMainFrame::ChangeStatusText(const CString &text)
  150. {
  151.     m_wndStatusBar.SetWindowText(text);
  152. }
  153.  
  154.  
  155. /////////////////////////////////////////////////////////////////////////////
  156. // CMainFrame message handlers
  157.  
  158. void CMainFrame::OnDropFiles(HDROP hDropInfo) 
  159. {
  160.     // TODO: Add your message handler code here and/or call default
  161.  
  162.     const int nFiles = ::DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0);
  163.  
  164.     for(int i = 0; i < nFiles; i++) {
  165.         TCHAR filename[_MAX_PATH];
  166.  
  167.         ::DragQueryFile(hDropInfo, i, filename, _MAX_PATH);
  168.  
  169.         extern CClamavApp theApp;
  170.  
  171.         theApp.Scan(filename);
  172.     }
  173.  
  174.       ::DragFinish(hDropInfo);
  175. }
  176.  
  177.